﻿@model Pager<SysDictionary>
@{
	ViewBag.Title = "下拉列表信息";
}
<div class="ui-widget-header">
	<div style="padding: 5px 10px; font-size: 120%">
		@ViewBag.Title
	</div>
</div>
@using (Ajax.BeginForm(null,new AjaxOptions { UpdateTargetId = "Main" }))
{
	<div class="ui-cell">
		<label>分类</label>
		@Html.DropDownList("Category")
	</div>
	<div class="ui-cell-bar">
		<input class="btn" type="submit" value="查找" />
		@Html.ActionLink("添加", "Edit", null, new { @class = "btn cat" })
	</div>
}
<div class="ui-data">
	<table>
		<thead>
			<tr>
				<td colspan="5">@Html.Partial("Pager", Model)</td>
			</tr>
			<tr>
				<th>分类</th>
				<th>名称</th>
				<th>值</th>
				<th>排序</th>
				<th>操作</th>
			</tr>
		</thead>
		<tbody>
			@foreach (var row in Model)
   {
			<tr>
				<td>@Html.DisplayFor(p=>row.Category)</td>
				<td>@Html.DisplayFor(p=>row.Caption)</td>
				<td>@Html.DisplayFor(p=>row.Worth)</td>
				<td>@Html.DisplayFor(p=>row.Sort)</td>
				<td>
					@Html.ActionLink("[修改]", "Edit", new { ID = row.ID }, new { @class = "cat" })
					@Html.ActionLink("[删除]", "Del", new { ID = row.ID }, new { @class = "subdel" })
				</td>
			</tr>
   }
			<tr>
				<td colspan="6">@Html.Partial("Pager", Model)</td>
			</tr>
		</tbody>
	</table>
</div>
<script type="text/javascript">
	window.datachanged = false;
	$("a.subdel").click(function () {
		if (confirm("你真的要删除这条数据吗？")) {
			$.post($(this).attr("href"), {}, function (res) {
				res.res && $(".btn:submit").submit();
			})
		}
		return false;
	})
	$(".cat").click(function () {
		$.get($(this).attr("href"), {}, function (data) {
			_d = $("<div id='subMain'></div>").html(data).dialog({
				title: "列表信息",
				modal: true,
				autoOpen: true,
				width: 550,
				position: ['0', 'center'],
				close: function () { _d.remove(); window.datachanged && $(".btn:submit").submit(); }
			});
		})
		return false;
	})
</script>